package hot;

/**
 * @author way
 * @create 2025-03-19 21:38
 */
public class _169_majorityElement {
    public int majorityElement(int[] nums) {
        int count = 0;
        int ans = 0;
        for (int num : nums) {
            if (count == 0) ans = num;

            if (num == ans) count++;
            else count--;
        }
        return ans;
    }
}
